package com.e3.basdoc.dept.client;

import java.util.ArrayList;
import java.util.List;

import com.e3.basdoc.dept.model.DeptModel;
import com.e3.template.tgf.TGFSimpleFormPanel;
import com.extjs.gxt.ui.client.widget.form.Field;

public class DeptFormPanel extends TGFSimpleFormPanel<DeptModel> {
	
//	private final static String[] LEFT_FIELD_NAME = { DeptModel.CODE, DeptModel.SHORT_NAME, DeptModel.PARENT_DEPT,
//		DeptModel.OFFICE_ADDRESS, DeptModel.FAX, DeptModel.TELPHONE, DeptModel.CONTACT_PERSON, DeptModel.MANAGER, DeptModel.STATUS,
//		DeptModel.ID };
//
//	private final static String[] RIGHT_FIELD_NAME = { DeptModel.NAME, DeptModel.TYPE, DeptModel.REGION, DeptModel.CONTACT_ADDRESS,
//		DeptModel.ZIPCODE, DeptModel.EMAIL, DeptModel.CONTACT_WAY, DeptModel.FOUND_TIME, DeptModel.CORPID };

	private final static String[] FIELD_NAMES = { 
		DeptModel.CODE,DeptModel.NAME,DeptModel.SHORT_NAME
		,DeptModel.TYPE, DeptModel.PARENT_DEPT,DeptModel.REGION
		,DeptModel.CONTACT_PERSON,DeptModel.CONTACT_ADDRESS, DeptModel.CONTACT_WAY
		,DeptModel.OFFICE_ADDRESS,DeptModel.ZIPCODE, DeptModel.FAX
		,DeptModel.TELPHONE,DeptModel.EMAIL, DeptModel.MANAGER, DeptModel.STATUS
		, DeptModel.FOUND_TIME,DeptModel.REMARK,DeptModel.ID };
	
	@Override
	public DeptModel createModelInstance() {
		return new DeptModel();
	}

//	@Override
//	public Map<Integer, List<Field<?>>> getFormFields() {
//		Map<Integer, List<Field<?>>> fields = new HashMap<Integer, List<Field<?>>>(3);
//		
//		fields.put(0, getColFields(LEFT_FIELD_NAME));
//		fields.put(1, getColFields(RIGHT_FIELD_NAME));
//		fields.put(2, getColFields(new String[]{DeptModel.REMARK}));
//		
//		return fields;
//	}

//	private List<Field<?>> getColFields(String[] fNames){
//		List<Field<?>> colFields = new ArrayList<Field<?>>(fNames.length);
//		for (String name : fNames) {
//			Field<?> field = DeptHelper.createFormField(name);
//			colFields.add(field);
//		}
//		return colFields;
//	}

	@Override
	public List<Field<?>> getFormFields() {
		List<Field<?>> fields = new ArrayList<Field<?>>(FIELD_NAMES.length);
		for (String name : FIELD_NAMES) {
			Field<?> field = DeptHelper.INSTANCE.createFormField(name);
			fields.add(field);
		}
		return fields;

	}

}
